import { defineStore } from 'pinia'
import { setStorage,removeStorage,getStorage } from '@/lib/storage'

const useMoment = defineStore('moment',{
	state: () => {
		return {
			momentMessage: null ,// 朋友圈新状态的通知消息
		}
	},
	actions: {
		// 设置朋友圈新状态
		setMomentMessage(data){
			this.momentMessage = data
			setStorage('momentStatus_' + data.user_id,this.momentMessage)
			uni.setTabBarBadge({
				index:2,
				text:''
			})
		},
		// 清空朋友圈新状态
		closeMomentMessage(data){
			this.momentMessage = null
			uni.removeTabBarBadge({
				index:2
			})
		}
	}
})

export default useMoment